package cn.edu.nit.sys.mapper;

import cn.edu.nit.sys.entity.Department;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author xiaobai
 * @Date 2022/8/27 21:54
 * @Version 1.0.0
 */
@Mapper
public interface DepartmentMapper extends BaseMapper<Department> {

    @Select("SELECT ANY_VALUE(id) AS id, name AS dept, GROUP_CONCAT(major_id) as major_id, GROUP_CONCAT(major) as major, dept_id " +
            "FROM sys_department GROUP BY dept_id, name ORDER BY id ASC")
    List<Department> getDepartmentList();

    @Update("update sys_department set name = #{name} where dept_id = #{id}")
    void updateDept(String name, String id);
}
